<?php echo $this->render('layouts/__header.phtml'); ?>
<?php echo $this->render('layouts/__nav.phtml'); ?>
	<h1><?php if($this->listType=="s"):?>My sent <?php else:?>My recieved <?php endif;?>message list</h1>
	<form action="<?php echo $this->baseUrl() ?>/user/messages" method="post" id="form1" name="form1">
	<input type="hidden" id="hidaction" name="hidaction" value=""/>
	<input type="hidden" id="hidid" name="hidid" value=""/>
	<div style="width:100%;text-align:right;margin:10px 0;"><?php if($this->listType=="s"):?><a href="/user/messages/type/r">My received messages</a><?php else: ?><a href="/user/messages/type/s">My sent messages</a><?php endif;?></div>
	<div id="tasklistbox">	
		<table class="normaltable" style="clear:both;">
		<tr class="tit">
			<td>ID</td>
			<!--<td>Reply</td>-->
			<td width="400">Content</td>
			<td>Author</td>
			<td>Time</td>
			<td>Actions</td>
		</tr>
		<?php if ($this->MessageCount == 0): ?>
		<tr><td colspan="5" style="color:#cc0000;height:50px;text-align:center"><b>Empty message List ...</b></td></tr>
		<?php else: ?>
		<?php foreach ($this->messagesList as $Message){?>
		<tr>
			<td><?php echo $Message['id']?></td>
			<!--<td><?php echo $Message['id']?></td>-->
			<td><?php echo $Message['content']?></td>
			<td><?php echo $Message['name']?></td>
			<td><?php echo $Message['adddate']?></td>
			<td><a onclick="replymsg(<?php echo $Message['id']?>);">reply</a></td>
		</tr>
		<?php }?>
		<?php endif; ?>
		</table>
	</div>
	<div class="listbottom">
		<div class="pagelist" <?php if (!$this->pager) {echo 'style="display:none"';} ?> ><?php echo $this->pager['prevStr'];?>&nbsp;<?php echo $this->pager['pageStr'];?>&nbsp;<?php echo $this->pager['nextStr'];?>&nbsp;<input id="pageto" type="text" /><a id="gopagebtn" href="javascript:;">Go</a></div>
	</div>
	</form>
		
	<div id="loadingbox" style="display:none;padding:2px 0px 0px 8px;width:125px;height:20px;text-align:center;position:absolute;top:0px;right:0px;background:#CC0000;color:#fff"><b>Loading ...</b></div>

<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/js/mootools.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/js/task.js"></script>
<script type="text/javascript">
var opentask = function(taskId, isOpen) {
	var request_uri = '<?php echo $this->this_url;?>?ajax=1&t='+(new Date()).getTime();
	new Ajax(request_uri, {
		method: 'get',
		evalScripts : true,
		data: Object.toQueryString({
			ti: taskId,
			io: isOpen
		}),
		update: 'tasklistbox'
	}).request();
}
window.addEvent('domready', function(){
	$('gopagebtn').addEvent('click', function(e){
		e = new Event(e);
		var page_to = parseInt($('pageto').value);
		var page_num = (page_to > 1) ? $('pageto').value : 1;
		var page_url = '<?php echo $this->base_url;?>index/p/'+page_num;
		redirect(page_url);
		e.stop();
		
	});
});
</script>
<?php echo $this->render('layouts/__footer.phtml'); ?>